package com.ecjtu.stadiumre_servations.controller;

import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.ecjtu.stadiumre_servations.entity.domain.GroupRecord;
import com.ecjtu.stadiumre_servations.response.Result;
import com.ecjtu.stadiumre_servations.service.GroupRecordService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.time.LocalDateTime;
@CrossOrigin
@RestController
@RequestMapping("/groupRecord")
public class GroupRecordController {
    @Autowired
    private GroupRecordService groupRecordService;
    @PutMapping("/createGroup")
    Result createGroup(@RequestParam String userid, @RequestParam String activityId,
                       @RequestParam LocalDateTime bookingStartTime, @RequestParam LocalDateTime bookingEndTime){
        return groupRecordService.createGroup(userid, activityId, bookingStartTime, bookingEndTime);
    }
    @PostMapping("/joinGroup")
    Result joinGroup(@RequestParam String userId, @RequestParam String activityId){
        return groupRecordService.joinGroup(userId, activityId);
    }
    @PostMapping("/getGroupByVenueId")
    Result getGroupByVenueId(Page<GroupRecord> page, @PathVariable String venueId){
        return groupRecordService.getGroupByVenueId(page, venueId);
    }
    @GetMapping("/listGroup")
    Result listGroup(Page<GroupRecord> page){
        return groupRecordService.listGroup(page);
    }
}
